package com.example.studyroom.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.example.studyroom.Entity.StudyRoom;
import com.example.studyroom.dto.StudyRoomAdmin.RoomAdminDTO;
import com.example.studyroom.mapper.StudyRoomMapper;
import com.example.studyroom.service.StudyRoomService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class StudyRoomServiceImpl extends ServiceImpl<StudyRoomMapper, StudyRoom> implements StudyRoomService {
    @Autowired
    private StudyRoomMapper studyRoomMapper;

    //获取所有的自习室信息
    @Override
    public List<StudyRoom> getAllStudyRooms() {
        return studyRoomMapper.getAllStudyRooms();
    }

    @Override
    public void addStudyRoom(StudyRoom StudyRoom) {
        studyRoomMapper.addStudyRoom(StudyRoom);
    }

    @Override
    public void deleteStudyRoom(Integer id) {
        studyRoomMapper.deleteStudyRoom(id);
    }

    @Override
    public void modifyStudyRoom(StudyRoom studyRoom) {
        studyRoomMapper.modifyStudyRoom(studyRoom);
    }

    //查看自习室负责的管理员
    @Override
    public List<RoomAdminDTO> getStudyRoomsByAdmin(String adminName) {
        return studyRoomMapper.findByAdminName(adminName);
    }

    //根据自习室名称查找自习室
    @Override
    public StudyRoom findByRoomName(String roomName) {
        // 实现根据roomName查找自习室信息的逻辑，使用mapper或者其他查询方式
        return studyRoomMapper.findByRoomName(roomName);
    }
    //更新剩余座位
    @Override
    public void updateCapacity(StudyRoom studyRoom) {
        studyRoomMapper.updateCapacity(studyRoom);
    }

    //更新负责的管理员
    @Override
    public void updateRoomAdmin(StudyRoom studyRoom) {
        studyRoomMapper.updateRoomAdmin(studyRoom);
    }

}
